package nina.yiyou.salary.input.util

import org.apache.poi.ss.usermodel.Row

class HeaderMapMaker {

  HeaderMapMaker(Row headerRow) {
    _headerRow = headerRow
  }

  Map<Integer, String> make() {
    return (0..<_headerRow.lastCellNum)
        .collect { _headerRow.getCell(it) }
        .collect { new CellValueGetter(it).get() }
        .indexed()
        .findAll { k, v -> v != null }
        .collectEntries { k, v -> [k, v.toString()] }
        .findAll { k, v -> v } as Map
  }

  private final Row _headerRow
}
